
import sys
import os
import glob
if 'build_ext' not in sys.argv:
    sys.argv.append('build_ext')
from distutils.core import setup
from Cython.Build import cythonize
temp_directory = "./build"  # 存放加载的路径
src_directory = "./"  # 存放加载的路径
# print(src_directory)
os.system(f"mkdir -p {temp_directory}/img")
os.system(f"cp -r ./img/* ./build/img/")
os.system(f"cp -r ./config.yaml ./main.py  ./build")

src_files = glob.glob(src_directory+"/*.py")
print(src_files)
for fs in src_files:
    if fs[-2:]=="py":
        setup(ext_modules=cythonize(fs, build_dir=temp_directory),
            options={"build": {"build_lib": './build'}},  # 将编译好的pyd文件放在python文件目录下
            language_level=0,
        )
        os.system(f"rm {fs}")
os.system(f"rm -r build/*.c")
